<?php

class wantu extends Model
{
	public function __construct()
	{
		//初始化
		$this->init_top();

		require_once (LIBS_PATH.'/wantu/alimedia/alimage.class.php');
	}

	//上传html文件到顽兔
	function upload_file($img){
		/*该测试方法主要是通过UploadPolicy设置文件上传到服务端的名称和路径*/
		/*第一步：（必须）引入AlibabaImage类，并设置AK和SK*/

		$aliImage  = new AlibabaImage(WANTU_AK,WANTU_SK);

		//*第二步：（必须）在上传策略UploadPolicy中指定用户空间名。也可以根据需要设置其他参数*
		$uploadPolicy = new UploadPolicy(WANTU_NAMESPACE);
		$uploadPolicy->dir = '/'.WANTU_dir; // 文件路径，(默认根目录"/")
		$uploadPolicy->name = 'image_'.time().'.jpg'; // 文件名，(若为空，则默认使用文件名)
		$res = $aliImage->uploadData( $img, $uploadPolicy );

		return $res;
	}

    function create_dir(){
        $aliImage  = new AlibabaImage(WANTU_AK,WANTU_SK);
        $res = $aliImage->createDir(WANTU_NAMESPACE, WANTU_dir);

        return $res;
    }

	function del_dir(){
        $aliImage  = new AlibabaImage(WANTU_AK,WANTU_SK);
        $res = $aliImage->deleteDir(WANTU_NAMESPACE, WANTU_dir);

		return $res;
	}
}